package com.yourenbang.lingyun.transaction.web.controller.petal;

import com.yourenbang.lingyun.core.base.controller.BaseController;
import com.yourenbang.lingyun.core.base.interceptor.ExcludeInterceptor;
import com.yourenbang.lingyun.core.message.Result;
import com.yourenbang.lingyun.core.util.KLog;
import com.yourenbang.lingyun.transaction.web.domain.dto.PullDataDTO;
import com.yourenbang.lingyun.transaction.web.service.petal.PullDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/transaction/pull")
public class PullDataController extends BaseController {
    @Autowired
    private PullDataService pullDataService;

    @Deprecated
    @ExcludeInterceptor
    @PostMapping(value = "/list/pledge/refund",produces = {"application/json;charset=UTF-8"})
    public Result<List<Map<String,Object>>> listPledgeRefundBill(@Validated @RequestBody PullDataDTO dto, BindingResult br){
        if (br.hasErrors()) {
            KLog.info(br.toString());
            return checkParamError(br);
        }
        KLog.info("[账单拉取]拉取押金退款账单开始...入参{}",dto);
        Result<List<Map<String,Object>>> listResult = pullDataService.pullPledgeRefundBill(dto);
        return listResult;
    }
}
